/**
 * Multicast project
 * Bidois Morgan & Thomas Nunes
 * 
 */

package Engine;

import Test.I_RecvMsgHandler;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.channels.SocketChannel;

public interface I_NioEngine {
	
	
	/**
	 * NIO engine initialization for server side
	 * @param the host address and port of the server
	 * @param handler handler instance for received messages, should implement @code IRecvMsgHandler interface
	 * @throws IOException 
	 */
	public void InitializeAsServer(InetAddress hostAddress, int port, I_RecvMsgHandler handler) 
			throws IOException;
	
	/**
	 * NIO engine initialization for client side
	 * T tries to connects to the server.
	 * @param the host address and port of the server
	 * @param handler handler instance for received messages, should implement @code IRecvMsgHandler interface
	 * @throws IOException 
	 */
	public void InitializeAsClient(InetAddress hostAddress, int port, I_RecvMsgHandler handler) 
			throws IOException;
	
	/**
	 * Send data on the client channel
	 * @param the data that should be sent  
	 */
	public void send(byte[] data, TypeMessage type,int idClient);
	
	
	/**
	 * Send data on the given channel
	 * @param the key of the channel on which data that should be sent
	 * @param the data that should be sent
	 */
	public void send(SocketChannel socketChannel, byte[] data, TypeMessage type,int idClient);
	
	
	/**
	 * Close the client channel
	 * @param the channel to close
	 */
	public void terminate() ;
	
}
